﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Main.Master" Inherits="System.Web.Mvc.ViewPage<Defect_Tracking_System.Helpers.PaginatedList<Defect_Tracking_System.Models.Project>>" %>
<%@ Import Namespace="Defect_Tracking_System.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Project
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <!--  start page-heading -->
	<div id="page-heading">
		<h1>All Projects</h1>
	</div>
	<!-- end page-heading -->
    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
	<tr>
		<th rowspan="3" class="sized"><img src="/Content/images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
		<th class="topleft"></th>
		<td id="tbl-border-top">
        </td>
		<th class="topright"></th>
		<th rowspan="3" class="sized"><img src="/Content/images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
	</tr>
	<tr>
		<td id="tbl-border-left"></td>
		<td>
		<!--  start content-table-inner ...................................................................... START -->
		<div id="content-table-inner">
		
			<!--  start table-content  -->
			<div id="table-content">
			
		
		 
				<!--  start product-table ..................................................................................... -->
				<table border="0" width="100%" cellpadding="0" cellspacing="0" class="product-table">
				<tr>
                    <th class="table-header-repeat line-left minwidth-1"><a href="#">Project Name</a></th>
					<th class="table-header-repeat line-left"><a href="#">CreatedDate</a></th>
					<th class="table-header-repeat line-left"><a href="#">Creator</a></th>
					<th class="table-header-repeat line-left"><a href="#">IsActive</a></th>
                    <% if ((bool)ViewData["EditRight"]) { %>
					<th class="table-header-repeat line-left"><a href="#">Options</a></th>
                    <%} %>
				</tr>
				<% for (int i=0; i < Model.Count; i++ )
                {
                %>
                        <tr> 
                            <td><%: Model.ElementAt(i).ProjectName%></td>
                            <td><%: Model.ElementAt(i).CreatedDate%></td>
                            <td><%: Model.ElementAt(i).Account.UserName%></td>
                            <td>
                                <% if (Model.ElementAt(i).IsActive)
                                   { %>
                                    <input type="checkbox" disabled="disabled" checked="checked" />
                                <%}
                                   else
                                   { %>
                                    <input type="checkbox" disabled="disabled" />
                                <%} %>
                            </td>
                             <% if ((bool)ViewData["EditRight"])
                                { %>
                            <td class="options-width">
                                    <%  
                                        bool IsTemp = false;
                                        List<TempLockProject> Li = null;
                                        TempLockProject Obj = null;
                                        if(ViewData["TempDelete"] != null)
                                        {
                                            Li = (List<TempLockProject>)ViewData["TempDelete"];
                                            
                                            foreach (TempLockProject Tp in Li)
                                            {
                                                if(Tp.ProjectId == Model.ElementAt(i).ProjectId.ToString())
                                                {
                                                    Obj = Tp;
                                                }
                                            }
                                            if (Obj != null)
                                            {
                                                IsTemp = true;
                                            }
                                        }
                                    %>
                                    <% 
                                        if (IsTemp)
                                        { 
                                    %>
                                       <a class="icon-8 info-tooltip" title="This project have been requested for deleting after <%: Obj.DeleteDate.Subtract(DateTime.Now).Days%> day(s)" />
                                        <% 
                                            if ((bool)ViewData["EditRight"])
                                            {
                                        %>
                                                <%: Html.ActionLink(" ", "RestoreProject", new { ProjectId = Model.ElementAt(i).ProjectId },  new { @class = "icon-9 info-tooltip", @title = "Restore" })%>
                                        <%
                                            }
                                        %>
                                        <%
                                        }
                                        else
                                        { 
                                        %>
                                        
                                            <%: Html.ActionLink(" ", "ViewDetails", new { ProjectId = Model.ElementAt(i).ProjectId }, new { @class = "icon-6 info-tooltip", @title = "Details" })%>
                                            <%: Html.ActionLink(" ", "EditProject", new { ProjectId = Model.ElementAt(i).ProjectId }, new { @class = "icon-1 info-tooltip", @title = "Edit" })%>
                                            <%: Html.ActionLink(" ", "Lookups", new { ProjectId = Model.ElementAt(i).ProjectId }, new { @class = "icon-11 info-tooltip", @title = "Lookups" })%>                                          
                                            <%: Html.ActionLink(" ", "ChangeProjectMember", new { ProjectId = Model.ElementAt(i).ProjectId }, new { @class = "icon-projectMember info-tooltip", @title = "Change Project Members" })%>
                                            <%: Html.ActionLink(" ", "DeleteProject", new { ProjectId = Model.ElementAt(i).ProjectId }, new { @class = "icon-2 info-tooltip", @title = "Delete" })%>                            
                                        <%
                                        }
                                        %>                         
					        </td>
                             <%} %>
                        </tr>
                <%} %>
				</table>
				<!--  end product-table................................... --> 
			</div>
			<!--  end content-table  -->
			
			<!--  start paging..................................................... -->
			<table cellspacing="0" cellpadding="0" border="0" id="paging-table">
			<tbody>
            <tr>
			<td>
                <% 
                    int PageCount = Model.TotalPages;
                    int Page = 1;
                    var RouteValue = Request.QueryString["PageIndex"];
                    if (RouteValue != null)
                        Int32.TryParse(RouteValue.ToString(), out Page);
                    int Previous = (Page == 1) ? 1 : Page - 1;
                    int First = 1;
                    int Next = (Page == PageCount) ? PageCount : Page + 1;
                    int Last = PageCount;
                %>
				<a class="page-far-left" href="?PageIndex=<%: First%>"></a>
				<a class="page-left" href="?PageIndex=<%: Previous%>"></a>
				<div class="page-info">Page <strong><%: Page %></strong> / <%: Model.TotalPages %></div>
				<a class="page-right" href="?PageIndex=<%: Next%>"></a>
				<a class="page-far-right" href="?PageIndex=<%: Last%>"></a>
			</td>
			<td>
			</td>
			</tr>
			</tbody></table>
			<!--  end paging................ -->
			
			<div class="clear"></div>
		 
		</div>
		<!--  end content-table-inner ............................................END  -->
		</td>
		<td id="tbl-border-right"></td>
	</tr>
	<tr>
		<th class="sized bottomleft"></th>
		<td id="tbl-border-bottom">&nbsp;</td>
		<th class="sized bottomright"></th>
	</tr>
	</table>
	<div class="clear">&nbsp;</div>
</asp:Content>

